1 Preprocessing & Cleaning

#load full csv data (preprocessed data)
cd <- read.csv("/Users/ramat/Desktop/cleaned.csv")
#recode to do analysis

1.1 Creating variables for regression

#changing up the variables for incomeRatio and trial conditions
#non white share/whiteShare: of white(or non-white) / total employee.
cd$nonwhite_share <- ((as.numeric(cd$nNonWhiteTrial))/25)*100
cd$white_share <- ((as.numeric(cd$nWhiteTrial))/25)*100

# both add up to 100: this is the control code (both add up to 100%)
cd$control <- (cd$nonwhite_share + cd$white_share)
100-cd$nonwhite_share == cd$white_share
cd$w_variations<- 100-cd$nw_variations
## summary:cond: white-more; nwmore; equal but for each variation (5)
cd$incomeShare_trial<-cd$nw_variations/cd$nNonWhiteTrial
cd$incomeShare_trial_w<-cd$w_variations/cd$nWhiteTrial

cd$incomeShare_difference <- cd$incomeShare_trial - cd$incomeShare_trial_w

2 Main Effect Analysis

2.1 fairness

m1 <- lme4::glmer(fairness ~ nonwhite_share*incomeShare_difference+ (1 | subject), cd, family = binomial(link = "logit"))

m1 <- lme4::glmer(fairness ~ nonwhite_share * incomeShare_difference+ (1 | subject), cd , family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5)))
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: fairness ~ nonwhite_share * incomeShare_difference + (1 | subject)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    621.6    642.6   -305.8    611.6      490 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.8935 -0.6608 -0.4573  0.8526  2.5006 
## 
## Random effects:
##  Groups  Name        Variance Std.Dev.
##  subject (Intercept) 0.9737   0.9868  
## Number of obs: 495, groups:  subject, 97
## 
## Fixed effects:
##                                        Estimate Std. Error z value Pr(>|z|)
## (Intercept)                           -0.387681   0.261834  -1.481    0.139
## nonwhite_share                        -0.011821   0.009203  -1.285    0.199
## incomeShare_difference                -0.337412   0.213042  -1.584    0.113
## nonwhite_share:incomeShare_difference  0.001149   0.007334   0.157    0.875
## 
## Correlation of Fixed Effects:
##             (Intr) nnwht_ incmS_
## nonwhit_shr -0.823              
## incmShr_dff  0.020 -0.016       
## nnwht_sh:S_ -0.023  0.034 -0.921

2.1.1 plot

fairness_plot <- interactions::interact_plot(m1, pred = nonwhite_share, modx = incomeShare_difference, x.label = "Non white Ratio", y.label = "0 = fair, 1 = unfair", legend.main = "income share difference") + ylim(c(0,1))

fairness_plot_maineffect <- annotate_figure(fairness_plot,
               top = text_grob("Fairness by Condition", color = "black", face = "bold", size = 14)) 
ggsave(plot = fairness_plot_maineffect, width = 8, height = 6, filename = "fairness_plot_maineffect.jpg")
knitr::include_graphics("fairness_plot_maineffect.jpg")

2.2 team work

m2 <- lme4::glmer(team_work ~ nonwhite_share*incomeShare_difference + (1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5)))
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: team_work ~ nonwhite_share * incomeShare_difference + (1 | X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    533.9    554.9   -261.9    523.9      490 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -0.8463 -0.5643 -0.4788 -0.4271  2.4432 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0        0       
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                        Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                           -1.481754   0.260631  -5.685 1.31e-08 ***
## nonwhite_share                         0.010539   0.009656   1.091    0.275    
## incomeShare_difference                -0.100560   0.218254  -0.461    0.645    
## nonwhite_share:incomeShare_difference -0.004750   0.007323  -0.649    0.517    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) nnwht_ incmS_
## nonwhit_shr -0.908              
## incmShr_dff  0.082 -0.076       
## nnwht_sh:S_ -0.087  0.105 -0.929
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')

2.2.1 plot

team_work_plot <- interactions::interact_plot(m2, pred = nonwhite_share, modx = incomeShare_difference, x.label = "Non white Ratio", y.label = "0 = team work well, 1 = team work not well", legend.main = "income share difference") + ylim(c(0,1))

team_work_plot_maineffect <- annotate_figure(team_work_plot,
               top = text_grob("Team Work by Condition", color = "black", face = "bold", size = 14)) 
ggsave(plot = team_work_plot_maineffect, width = 8, height = 6, filename = "team_work_plot_maineffect.jpg")
knitr::include_graphics("team_work_plot_maineffect.jpg")

2.3 work in team

m3 <- lme4::glmer(work_in_team ~ nonwhite_share*incomeShare_difference + (1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5)))
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: work_in_team ~ nonwhite_share * incomeShare_difference + (1 |      X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    668.4    689.4   -329.2    658.4      490 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.3333 -0.8906 -0.6649  0.9903  1.6359 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0        0       
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                         Estimate Std. Error z value Pr(>|z|)  
## (Intercept)                           -0.2498162  0.2164031  -1.154   0.2483  
## nonwhite_share                         0.0011320  0.0081868   0.138   0.8900  
## incomeShare_difference                -0.3375464  0.1838674  -1.836   0.0664 .
## nonwhite_share:incomeShare_difference  0.0006399  0.0062831   0.102   0.9189  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) nnwht_ incmS_
## nonwhit_shr -0.904              
## incmShr_dff  0.005  0.001       
## nnwht_sh:S_ -0.002 -0.001 -0.924
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')

2.3.1 plot

work_in_team_plot <- interactions::interact_plot(m3, pred = nonwhite_share, modx = incomeShare_difference, x.label = "Non white Ratio", y.label = "0 = want to work in team, 1 = do not want to work in team", legend.main = "income share difference") + ylim(c(0,1))

work_in_team_plot_maineffect_nw <- annotate_figure(work_in_team_plot,
               top = text_grob("Work in Team by Condition", color = "black", face = "bold", size = 14)) 
ggsave(plot = work_in_team_plot_maineffect_nw, width = 8, height = 6, filename = "work_in_team_maineffect_nw.jpg")
knitr::include_graphics("work_in_team_maineffect_nw.jpg")

2.4 distrust

m4 <- lme4::glmer(distrust ~ nonwhite_share*incomeShare_difference + (1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5)))
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: distrust ~ nonwhite_share * incomeShare_difference + (1 | X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    645.8    666.9   -317.9    635.8      490 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.0789 -0.7822 -0.6089  1.0529  1.9178 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0        0       
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                        Estimate Std. Error z value Pr(>|z|)  
## (Intercept)                           -0.435225   0.221298  -1.967   0.0492 *
## nonwhite_share                        -0.003500   0.008399  -0.417   0.6768  
## incomeShare_difference                -0.349539   0.187804  -1.861   0.0627 .
## nonwhite_share:incomeShare_difference  0.001468   0.006424   0.228   0.8193  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) nnwht_ incmS_
## nonwhit_shr -0.903              
## incmShr_dff  0.052 -0.043       
## nnwht_sh:S_ -0.050  0.056 -0.924
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')

2.4.1 plot

distrust_plot_nw <- interactions::interact_plot(m4, pred = nonwhite_share, modx = incomeShare_difference, x.label = "Non white Ratio", y.label = "0 = trust , 1 = distrust", legend.main = "income share difference") + ylim(c(0,1))

distrust_maineffect_nw <- annotate_figure(distrust_plot_nw,
               top = text_grob("Trust by Condition", color = "black", face = "bold", size = 14)) 
ggsave(plot = distrust_maineffect_nw, width = 10, height = 8, filename = "distrust_maineffect_nw.jpg")
knitr::include_graphics("distrust_maineffect_nw.jpg")

2.5 Table with Results

M1 = Fairness NW (DV), M2 = Team Work NW (DV), M3 = Want to work in team NW (DV), M4 = Distrust NW (DV)
  Model 1 Model 2 Model 3 Model 4
(Intercept) -.388 -1.482*** -.250 -.435*
  (.262) (.261) (.216) (.221)
nonwhite_share -.012 .011 .001 -.004
  (.009) (.010) (.008) (.008)
incomeShare_difference -.337 -.101 -.338 -.350
  (.213) (.218) (.184) (.188)
nonwhite_share:incomeShare_difference .001 -.005 .001 .001
  (.007) (.007) (.006) (.006)
AIC 621.589 533.855 668.406 645.838
BIC 642.611 554.878 689.429 666.861
Log Likelihood -305.794 -261.928 -329.203 -317.919
Num. obs. 495 495 495 495
Num. groups: subject 97      
Var: subject (Intercept) .974      
Num. groups: X   495 495 495
Var: X (Intercept)   .000 .000 .000
***p < 0.001; **p < 0.01; *p < 0.05
fairness_nw_w <- ggarrange(fairness_plot_maineffect_w,fairness_plot_maineffect, ncol = 2, nrow = 2, common.legend = T)
ggsave(plot = fairness_nw_w, width = 10, height = 10, filename = "fairness_nw_w.jpg")
knitr::include_graphics("fairness_nw_w.jpg")

want_to_work_in_team_nw_w <- ggarrange(work_in_team_plot_maineffect_w,work_in_team_plot_maineffect_nw, ncol = 2, nrow = 2, common.legend = T)
ggsave(plot = want_to_work_in_team_nw_w, width = 10, height = 10, filename = "want_to_work_in_team_nw_w.jpg")
knitr::include_graphics("want_to_work_in_team_nw_w.jpg")

distrust_nw_w <- ggarrange(distrust_maineffect_w,distrust_maineffect_nw, ncol = 2, nrow = 2, common.legend = T)
ggsave(plot = distrust_nw_w, width = 10, height = 10, filename = "distrust_nw_w.jpg")
knitr::include_graphics("distrust_nw_w.jpg")

3 Main Effects Analysis with control variables

3.1 fairness

m9 <- lme4::glmer(fairness ~ nonwhite_share*incomeShare_difference + age + gender + ethnic + edu + marital + children + employment + income_log + ladder + PoliticalOrientation+(1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5)))
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: fairness ~ nonwhite_share * incomeShare_difference + age + gender +  
##     ethnic + edu + marital + children + employment + income_log +  
##     ladder + PoliticalOrientation + (1 | X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    649.8    742.3   -302.9    605.8      473 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.7898 -0.7696 -0.5067  1.0201  2.8114 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0        0       
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                         Estimate Std. Error z value Pr(>|z|)   
## (Intercept)                            4.7345805  1.8082964   2.618  0.00884 **
## nonwhite_share                        -0.0102955  0.0086708  -1.187  0.23508   
## incomeShare_difference                -0.3036798  0.1952169  -1.556  0.11980   
## age                                   -0.0015560  0.0109295  -0.142  0.88679   
## gendero                                0.4666909  1.0376514   0.450  0.65289   
## ethnic1                               -0.5578602  0.2428919  -2.297  0.02163 * 
## edu2                                   0.7423404  0.8648553   0.858  0.39070   
## edu3                                   0.3457048  0.8596867   0.402  0.68759   
## edu4                                   0.1758548  0.9091737   0.193  0.84663   
## edu5                                   0.4771796  0.8782200   0.543  0.58689   
## edu6                                   0.4390157  0.9236161   0.475  0.63456   
## marital3                              -0.8615496  0.9713772  -0.887  0.37511   
## marital4                              -0.0923857  0.3733393  -0.247  0.80455   
## children                              -0.0349484  0.1798081  -0.194  0.84589   
## employmentFull-time                    0.1690527  0.2818873   0.600  0.54869   
## employmentPrefer not to answer         0.2601685  0.3209543   0.811  0.41759   
## employmentUnemployed                   1.4241994  1.0400311   1.369  0.17088   
## income_log                            -0.3766638  0.1302117  -2.893  0.00382 **
## ladder                                -0.2060091  0.0730639  -2.820  0.00481 **
## PoliticalOrientation                  -0.0554099  0.0701607  -0.790  0.42967   
## nonwhite_share:incomeShare_difference  0.0004449  0.0067254   0.066  0.94725   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation matrix not shown by default, as p = 21 > 12.
## Use print(x, correlation=TRUE)  or
##     vcov(x)        if you need it
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')

3.1.1 plot

knitr::include_graphics("fairness_maineffect_cov_nw.jpg")

3.2 work in team

m10 <- lme4::glmer(work_in_team ~ nonwhite_share*incomeShare_difference + age + gender + ethnic + edu + marital + children + employment + income_log + ladder + PoliticalOrientation+(1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5)))
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: work_in_team ~ nonwhite_share * incomeShare_difference + age +  
##     gender + ethnic + edu + marital + children + employment +  
##     income_log + ladder + PoliticalOrientation + (1 | X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    667.3    759.8   -311.7    623.3      473 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.6345 -0.8379 -0.5129  0.9530  2.1621 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0.01214  0.1102  
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                        Estimate Std. Error z value Pr(>|z|)   
## (Intercept)                            5.193920   1.853198   2.803  0.00507 **
## nonwhite_share                         0.001359   0.008505   0.160  0.87303   
## incomeShare_difference                -0.418178   0.198588  -2.106  0.03523 * 
## age                                   -0.031700   0.011773  -2.693  0.00709 **
## gendero                                1.038017   1.047316   0.991  0.32163   
## ethnic1                               -0.220365   0.232109  -0.949  0.34242   
## edu2                                   0.669761   0.875144   0.765  0.44408   
## edu3                                   0.379555   0.868148   0.437  0.66197   
## edu4                                  -0.205076   0.919201  -0.223  0.82346   
## edu5                                   0.524671   0.885014   0.593  0.55329   
## edu6                                   0.459814   0.930200   0.494  0.62108   
## marital3                              -0.877807   0.978260  -0.897  0.36955   
## marital4                              -0.422086   0.377509  -1.118  0.26353   
## children                               0.036226   0.173555   0.209  0.83466   
## employmentFull-time                    0.202409   0.274214   0.738  0.46043   
## employmentPrefer not to answer         0.582263   0.317114   1.836  0.06634 . 
## employmentUnemployed                  -1.008654   1.225337  -0.823  0.41041   
## income_log                            -0.345502   0.132700  -2.604  0.00922 **
## ladder                                -0.189488   0.073510  -2.578  0.00995 **
## PoliticalOrientation                  -0.007742   0.068114  -0.114  0.90950   
## nonwhite_share:incomeShare_difference  0.002034   0.006690   0.304  0.76105   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation matrix not shown by default, as p = 21 > 12.
## Use print(x, correlation=TRUE)  or
##     vcov(x)        if you need it
## optimizer (bobyqa) convergence code: 0 (OK)
## Model failed to converge with max|grad| = 0.0119422 (tol = 0.002, component 1)
## Model is nearly unidentifiable: large eigenvalue ratio
##  - Rescale variables?

3.2.1 plot

work_in_team_maineffect <- interactions::interact_plot(m10, pred = nonwhite_share, modx = incomeShare_difference, x.label = "income share held by non white employees", y.label = "0 = want to work in team, 1 = do not want to work in team", legend.main = "income share difference") + ylim(c(0,1))

work_in_team_maineffect_annotated <- annotate_figure(work_in_team_maineffect,
               top = text_grob("Work in Team by Condition", color = "black", face = "bold", size = 14)) 
ggsave(plot = work_in_team_maineffect_annotated, width = 8, height = 6, filename = "work_in_team_cov_nw.jpg")
knitr::include_graphics("work_in_team_cov_nw.jpg")

3.3 team work

m11 <- lme4::glmer(team_work ~ nonwhite_share*incomeShare_difference + age + gender + ethnic + edu + marital + children + employment + income_log + ladder + PoliticalOrientation+(1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5)))
## Warning in vcov.merMod(object, use.hessian = use.hessian): variance-covariance matrix computed from finite-difference Hessian is
## not positive definite or contains NA values: falling back to var-cov estimated from RX
## Warning in vcov.merMod(object, correlation = correlation, sigm = sig): variance-covariance matrix computed from finite-difference Hessian is
## not positive definite or contains NA values: falling back to var-cov estimated from RX
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: team_work ~ nonwhite_share * incomeShare_difference + age + gender +  
##     ethnic + edu + marital + children + employment + income_log +  
##     ladder + PoliticalOrientation + (1 | X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    529.1    621.6   -242.5    485.1      473 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.1043 -0.5913 -0.4166 -0.0800  4.8883 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0        0       
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                         Estimate Std. Error z value Pr(>|z|)
## (Intercept)                            4.272e+00  2.028e+00   2.106 0.035196
## nonwhite_share                         1.140e-02  1.003e-02   1.137 0.255662
## incomeShare_difference                -8.113e-02  2.319e-01  -0.350 0.726471
## age                                    5.824e-03  1.261e-02   0.462 0.644278
## gendero                               -1.532e+01  2.908e+03  -0.005 0.995796
## ethnic1                                1.011e-01  2.697e-01   0.375 0.707752
## edu2                                   8.731e-01  1.025e+00   0.852 0.394221
## edu3                                   3.659e-01  1.011e+00   0.362 0.717353
## edu4                                   1.848e-01  1.065e+00   0.174 0.862237
## edu5                                   4.167e-01  1.041e+00   0.400 0.688985
## edu6                                   4.096e-02  1.086e+00   0.038 0.969921
## marital3                               3.891e-01  1.074e+00   0.362 0.716992
## marital4                               2.742e-01  4.298e-01   0.638 0.523463
## children                               5.857e-02  2.190e-01   0.267 0.789174
## employmentFull-time                    1.103e+00  3.565e-01   3.095 0.001970
## employmentPrefer not to answer         4.013e-01  4.022e-01   0.998 0.318342
## employmentUnemployed                  -1.514e+01  2.897e+03  -0.005 0.995831
## income_log                            -5.481e-01  1.495e-01  -3.666 0.000246
## ladder                                -1.870e-01  8.504e-02  -2.200 0.027842
## PoliticalOrientation                  -1.311e-01  8.186e-02  -1.602 0.109229
## nonwhite_share:incomeShare_difference -4.490e-03  7.763e-03  -0.578 0.562990
##                                          
## (Intercept)                           *  
## nonwhite_share                           
## incomeShare_difference                   
## age                                      
## gendero                                  
## ethnic1                                  
## edu2                                     
## edu3                                     
## edu4                                     
## edu5                                     
## edu6                                     
## marital3                                 
## marital4                                 
## children                                 
## employmentFull-time                   ** 
## employmentPrefer not to answer           
## employmentUnemployed                     
## income_log                            ***
## ladder                                *  
## PoliticalOrientation                     
## nonwhite_share:incomeShare_difference    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation matrix not shown by default, as p = 21 > 12.
## Use print(x, correlation=TRUE)  or
##     vcov(x)        if you need it
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')

3.3.1 plot

team_work_maineffect <- interactions::interact_plot(m11, pred = nonwhite_share, modx = incomeShare_difference, x.label = "income share held by non white employees", y.label = "0 = team work well, 1 = team work not well", legend.main = "income share difference") + ylim(c(0,1))

team_work_maineffect_annotated <- annotate_figure(team_work_maineffect,
               top = text_grob("Team work by Condition", color = "black", face = "bold", size = 14)) 
ggsave(plot = work_in_team_maineffect_annotated, width = 8, height = 6, filename = "team_work_cov_nw.jpg")
knitr::include_graphics("team_work_cov_nw.jpg")

3.4 trust of the organization’s leadership

m12 <- lme4::glmer(distrust ~ nonwhite_share*incomeShare_difference + age + gender + ethnic + edu + marital + children + employment + income_log + ladder + PoliticalOrientation+(1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5)))
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: distrust ~ nonwhite_share * incomeShare_difference + age + gender +  
##     ethnic + edu + marital + children + employment + income_log +  
##     ladder + PoliticalOrientation + (1 | X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    634.6    727.1   -295.3    590.6      473 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.6316 -0.7653 -0.4628  0.9513  3.3145 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0.01692  0.1301  
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                        Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                            4.570566   1.884199   2.426 0.015277 *  
## nonwhite_share                        -0.003918   0.008831  -0.444 0.657253    
## incomeShare_difference                -0.416197   0.205520  -2.025 0.042857 *  
## age                                   -0.004351   0.011102  -0.392 0.695106    
## gendero                                0.850472   1.056211   0.805 0.420698    
## ethnic1                               -0.303136   0.243061  -1.247 0.212339    
## edu2                                   0.988056   0.880294   1.122 0.261686    
## edu3                                   0.820194   0.872049   0.941 0.346943    
## edu4                                  -0.172349   0.925674  -0.186 0.852298    
## edu5                                   0.591181   0.892376   0.662 0.507664    
## edu6                                   0.847149   0.936663   0.904 0.365766    
## marital3                              -1.089969   0.986485  -1.105 0.269202    
## marital4                               0.264894   0.387563   0.683 0.494299    
## children                               0.157669   0.185321   0.851 0.394888    
## employmentFull-time                    0.907863   0.316009   2.873 0.004067 ** 
## employmentPrefer not to answer         1.244588   0.354687   3.509 0.000450 ***
## employmentUnemployed                   0.918859   1.059086   0.868 0.385615    
## income_log                            -0.482925   0.142447  -3.390 0.000698 ***
## ladder                                -0.201787   0.077753  -2.595 0.009453 ** 
## PoliticalOrientation                  -0.063577   0.071446  -0.890 0.373536    
## nonwhite_share:incomeShare_difference  0.002722   0.006914   0.394 0.693781    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation matrix not shown by default, as p = 21 > 12.
## Use print(x, correlation=TRUE)  or
##     vcov(x)        if you need it
## optimizer (bobyqa) convergence code: 0 (OK)
## Model failed to converge with max|grad| = 0.0199892 (tol = 0.002, component 1)
## Model is nearly unidentifiable: large eigenvalue ratio
##  - Rescale variables?

3.4.1 plot

distrust_maineffect <- interactions::interact_plot(m12, pred = nonwhite_share, modx = incomeShare_difference, x.label = "income share held by non white employees", y.label = "0 = trust , 1 = distrust", legend.main = "income share difference") + ylim(c(0,1))

distrust_maineffect_annotated <- annotate_figure(distrust_maineffect,
               top = text_grob("Trust by Condition", color = "black", face = "bold", size = 14)) 
ggsave(plot = distrust_maineffect_annotated, width = 8, height = 6, filename = "distrust_cov_nw.jpg")
knitr::include_graphics("distrust_cov_nw.jpg")

3.5 Table

M9 = Fairness nw (DV), M10 = Want to work in team nw(DV), M11 = Trust org nw (DV), M12 = Distrust nw (DV), M13 = Fairness w (DV), M14 = Want to work in team w (DV), M15 = Trust org w(DV), M16 = Distrust w (DV)
  Model 1 Model 2 Model 3 Model 4 Model 5 Model 6 Model 7 Model 8
(Intercept) 4.735** 5.194** 4.272* 4.571* 3.705 5.328** 5.412* 4.178*
  (1.808) (1.853) (2.028) (1.884) (1.898) (1.951) (2.165) (1.973)
nonwhite_share -.010 .001 .011 -.004        
  (.009) (.009) (.010) (.009)        
incomeShare_difference -.304 -.418* -.081 -.416* -.259 -.214 -.530 -.143
  (.195) (.199) (.232) (.206) (.498) (.494) (.567) (.510)
age -.002 -.032** .006 -.004 -.002 -.032** .006 -.004
  (.011) (.012) (.013) (.011) (.011) (.012) (.013) (.011)
gendero .467 1.038 -15.324 .850 .467 1.038 -15.324 .850
  (1.038) (1.047) (2908.416) (1.056) (1.038) (1.047) (512.001) (1.056)
ethnic1 -.558* -.220 .101 -.303 -.558* -.220 .101 -.303
  (.243) (.232) (.270) (.243) (.243) (.232) (.270) (.243)
edu2 .742 .670 .873 .988 .742 .670 .873 .987
  (.865) (.875) (1.025) (.880) (.865) (.875) (1.025) (.880)
edu3 .346 .380 .366 .820 .346 .380 .366 .819
  (.860) (.868) (1.011) (.872) (.860) (.868) (1.011) (.872)
edu4 .176 -.205 .185 -.172 .176 -.205 .185 -.172
  (.909) (.919) (1.065) (.926) (.909) (.919) (1.065) (.926)
edu5 .477 .525 .417 .591 .477 .525 .417 .591
  (.878) (.885) (1.041) (.892) (.878) (.885) (1.041) (.892)
edu6 .439 .460 .041 .847 .439 .460 .041 .847
  (.924) (.930) (1.086) (.937) (.924) (.930) (1.086) (.937)
marital3 -.862 -.878 .389 -1.090 -.862 -.878 .389 -1.090
  (.971) (.978) (1.074) (.986) (.971) (.978) (1.073) (.986)
marital4 -.092 -.422 .274 .265 -.092 -.422 .274 .264
  (.373) (.378) (.430) (.388) (.373) (.377) (.430) (.387)
children -.035 .036 .059 .158 -.035 .036 .059 .157
  (.180) (.174) (.219) (.185) (.180) (.174) (.219) (.185)
employmentFull-time .169 .202 1.103** .908** .169 .202 1.103** .907**
  (.282) (.274) (.357) (.316) (.282) (.274) (.357) (.316)
employmentPrefer not to answer .260 .582 .401 1.245*** .260 .582 .401 1.243***
  (.321) (.317) (.402) (.355) (.321) (.317) (.402) (.354)
employmentUnemployed 1.424 -1.009 -15.136 .919 1.424 -1.009 -15.136 .918
  (1.040) (1.225) (2896.833) (1.059) (1.040) (1.225) (362.039) (1.059)
income_log -.377** -.346** -.548*** -.483*** -.377** -.346** -.548*** -.483***
  (.130) (.133) (.150) (.142) (.130) (.133) (.149) (.142)
ladder -.206** -.189** -.187* -.202** -.206** -.189* -.187* -.202**
  (.073) (.074) (.085) (.078) (.073) (.073) (.085) (.078)
PoliticalOrientation -.055 -.008 -.131 -.064 -.055 -.008 -.131 -.064
  (.070) (.068) (.082) (.071) (.070) (.068) (.082) (.071)
nonwhite_share:incomeShare_difference .000 .002 -.004 .003        
  (.007) (.007) (.008) (.007)        
white_share         .010 -.001 -.011 .004
          (.009) (.009) (.010) (.009)
white_share:incomeShare_difference         -.000 -.002 .004 -.003
          (.007) (.007) (.008) (.007)
AIC 649.813 667.312 529.065 634.644 649.813 667.312 529.065 634.644
BIC 742.313 759.812 621.565 727.144 742.313 759.812 621.565 727.145
Log Likelihood -302.906 -311.656 -242.533 -295.322 -302.906 -311.656 -242.533 -295.322
Num. obs. 495 495 495 495 495 495 495 495
Num. groups: X 495 495 495 495 495 495 495 495
Var: X (Intercept) .000 .012 .000 .017 .000 .012 .000 .017
***p < 0.001; **p < 0.01; *p < 0.05

4 Moderator Analysis: Political Orientation

4.1 fairness

summary(m1_1 <- lme4::glmer(fairness ~ PoliticalOrientation*nonwhite_share*incomeShare_difference +(1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5))))
## boundary (singular) fit: see help('isSingular')
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: 
## fairness ~ PoliticalOrientation * nonwhite_share * incomeShare_difference +  
##     (1 | X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    652.5    690.3   -317.3    634.5      486 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.0896 -0.7827 -0.6244  1.1027  2.5349 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0        0       
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                                              Estimate
## (Intercept)                                                -0.4302977
## PoliticalOrientation                                        0.0363387
## nonwhite_share                                              0.0056792
## incomeShare_difference                                     -0.3031909
## PoliticalOrientation:nonwhite_share                        -0.0041353
## PoliticalOrientation:incomeShare_difference                -0.0033735
## nonwhite_share:incomeShare_difference                       0.0032078
## PoliticalOrientation:nonwhite_share:incomeShare_difference -0.0006583
##                                                            Std. Error z value
## (Intercept)                                                 0.5958150  -0.722
## PoliticalOrientation                                        0.1479732   0.246
## nonwhite_share                                              0.0226885   0.250
## incomeShare_difference                                      0.5066129  -0.598
## PoliticalOrientation:nonwhite_share                         0.0056759  -0.729
## PoliticalOrientation:incomeShare_difference                 0.1249843  -0.027
## nonwhite_share:incomeShare_difference                       0.0173283   0.185
## PoliticalOrientation:nonwhite_share:incomeShare_difference  0.0043372  -0.152
##                                                            Pr(>|z|)
## (Intercept)                                                   0.470
## PoliticalOrientation                                          0.806
## nonwhite_share                                                0.802
## incomeShare_difference                                        0.550
## PoliticalOrientation:nonwhite_share                           0.466
## PoliticalOrientation:incomeShare_difference                   0.978
## nonwhite_share:incomeShare_difference                         0.853
## PoliticalOrientation:nonwhite_share:incomeShare_difference    0.879
## 
## Correlation of Fixed Effects:
##             (Intr) PltclO nnwht_ incmS_ PltO:_ PlO:S_ nn_:S_
## PltclOrnttn -0.929                                          
## nonwhit_shr -0.903  0.841                                   
## incmShr_dff  0.048 -0.056 -0.038                            
## PltclOrnt:_  0.835 -0.901 -0.928  0.044                     
## PltclOrn:S_ -0.056  0.071  0.045 -0.930 -0.057              
## nnwht_sh:S_ -0.045  0.053  0.048 -0.924 -0.055  0.862       
## PltclO:_:S_  0.052 -0.066 -0.055  0.849  0.071 -0.916 -0.929
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
plot1_1 <- interact_plot(model = m1_1, pred = nonwhite_share, modx = incomeShare_difference, mod2 = PoliticalOrientation, x.label = "Non white Ratio", y.label = "0 = fair, 1 = unfair", legend.main = "Political Orientation") + ylim(c(0,1))

ggsave(plot = plot1_1, width = 10, height = 8, filename = "Pol_Fairness_nw.jpg")

4.2 want to work in team

summary(m2_1 <- lme4::glmer(work_in_team ~ PoliticalOrientation*nonwhite_share*incomeShare_difference +(1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5))))
## boundary (singular) fit: see help('isSingular')
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: 
## work_in_team ~ PoliticalOrientation * nonwhite_share * incomeShare_difference +  
##     (1 | X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    673.4    711.2   -327.7    655.4      486 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.3636 -0.8831 -0.6552  0.9994  2.3676 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0        0       
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                                             Estimate Std. Error
## (Intercept)                                                -0.841850   0.590198
## PoliticalOrientation                                        0.157621   0.145860
## nonwhite_share                                              0.029885   0.022272
## incomeShare_difference                                     -0.312726   0.501744
## PoliticalOrientation:nonwhite_share                        -0.007691   0.005539
## PoliticalOrientation:incomeShare_difference                -0.005454   0.123453
## nonwhite_share:incomeShare_difference                       0.005680   0.017059
## PoliticalOrientation:nonwhite_share:incomeShare_difference -0.001469   0.004258
##                                                            z value Pr(>|z|)
## (Intercept)                                                 -1.426    0.154
## PoliticalOrientation                                         1.081    0.280
## nonwhite_share                                               1.342    0.180
## incomeShare_difference                                      -0.623    0.533
## PoliticalOrientation:nonwhite_share                         -1.389    0.165
## PoliticalOrientation:incomeShare_difference                 -0.044    0.965
## nonwhite_share:incomeShare_difference                        0.333    0.739
## PoliticalOrientation:nonwhite_share:incomeShare_difference  -0.345    0.730
## 
## Correlation of Fixed Effects:
##             (Intr) PltclO nnwht_ incmS_ PltO:_ PlO:S_ nn_:S_
## PltclOrnttn -0.930                                          
## nonwhit_shr -0.905  0.843                                   
## incmShr_dff  0.021 -0.026 -0.008                            
## PltclOrnt:_  0.838 -0.904 -0.929  0.014                     
## PltclOrn:S_ -0.027  0.033  0.014 -0.930 -0.020              
## nnwht_sh:S_ -0.012  0.019  0.002 -0.926 -0.011  0.863       
## PltclO:_:S_  0.018 -0.026 -0.011  0.851  0.021 -0.918 -0.929
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
plot2_1 <- interact_plot(model = m2_1, pred = nonwhite_share, modx = incomeShare_difference, mod2 = PoliticalOrientation, x.label = "Non white Ratio", y.label = "0 = want to work in team, 1 = do not want to work in team", legend.main = "Political Orientation") + ylim(c(0,1))

ggsave(plot = plot2_1, width = 10, height = 8, filename = "Pol_Want_to_work_nw.jpg")

4.3 team work

summary(m3_1 <- lme4::glmer(team_work ~ PoliticalOrientation*nonwhite_share*incomeShare_difference +(1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5))))
## boundary (singular) fit: see help('isSingular')
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: 
## team_work ~ PoliticalOrientation * nonwhite_share * incomeShare_difference +  
##     (1 | X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    529.7    567.5   -255.8    511.7      486 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -0.9726 -0.5730 -0.4767 -0.2467  5.4726 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0        0       
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                                             Estimate Std. Error
## (Intercept)                                                -2.395034   0.716484
## PoliticalOrientation                                        0.253311   0.176868
## nonwhite_share                                              0.065877   0.026244
## incomeShare_difference                                      0.043031   0.596454
## PoliticalOrientation:nonwhite_share                        -0.015748   0.006799
## PoliticalOrientation:incomeShare_difference                -0.026571   0.146549
## nonwhite_share:incomeShare_difference                       0.007171   0.019779
## PoliticalOrientation:nonwhite_share:incomeShare_difference -0.004160   0.005092
##                                                            z value Pr(>|z|)    
## (Intercept)                                                 -3.343 0.000829 ***
## PoliticalOrientation                                         1.432 0.152086    
## nonwhite_share                                               2.510 0.012068 *  
## incomeShare_difference                                       0.072 0.942487    
## PoliticalOrientation:nonwhite_share                         -2.316 0.020547 *  
## PoliticalOrientation:incomeShare_difference                 -0.181 0.856124    
## nonwhite_share:incomeShare_difference                        0.363 0.716959    
## PoliticalOrientation:nonwhite_share:incomeShare_difference  -0.817 0.413998    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) PltclO nnwht_ incmS_ PltO:_ PlO:S_ nn_:S_
## PltclOrnttn -0.929                                          
## nonwhit_shr -0.911  0.860                                   
## incmShr_dff  0.044 -0.069 -0.041                            
## PltclOrnt:_  0.819 -0.901 -0.924  0.064                     
## PltclOrn:S_ -0.070  0.112  0.068 -0.930 -0.109              
## nnwht_sh:S_ -0.050  0.081  0.066 -0.930 -0.105  0.875       
## PltclO:_:S_  0.077 -0.129 -0.106  0.834  0.173 -0.912 -0.924
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
plot3_1 <- interact_plot(model = m3_1, pred = nonwhite_share, modx = incomeShare_difference, mod2 = PoliticalOrientation, x.label = "Non white Ratio", y.label = "0 = team work well, 1 = team work not well", legend.main = "Political Orientation") + ylim(c(0,1))

ggsave(plot = plot3_1, width = 10, height = 8, filename = "Pol_team_work_nw.jpg")

4.4 distrust

summary(m4_1 <- lme4::glmer(distrust ~ PoliticalOrientation*nonwhite_share*incomeShare_difference +(1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5))))
## boundary (singular) fit: see help('isSingular')
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: 
## distrust ~ PoliticalOrientation * nonwhite_share * incomeShare_difference +  
##     (1 | X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    641.1    679.0   -311.6    623.1      486 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.4400 -0.8102 -0.5809  1.1019  3.7479 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0        0       
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                                             Estimate Std. Error
## (Intercept)                                                -0.677648   0.600786
## PoliticalOrientation                                        0.068509   0.151371
## nonwhite_share                                              0.020112   0.022833
## incomeShare_difference                                     -0.149961   0.510440
## PoliticalOrientation:nonwhite_share                        -0.006765   0.005862
## PoliticalOrientation:incomeShare_difference                -0.048148   0.128715
## nonwhite_share:incomeShare_difference                       0.015126   0.017503
## PoliticalOrientation:nonwhite_share:incomeShare_difference -0.004298   0.004547
##                                                            z value Pr(>|z|)
## (Intercept)                                                 -1.128    0.259
## PoliticalOrientation                                         0.453    0.651
## nonwhite_share                                               0.881    0.378
## incomeShare_difference                                      -0.294    0.769
## PoliticalOrientation:nonwhite_share                         -1.154    0.248
## PoliticalOrientation:incomeShare_difference                 -0.374    0.708
## nonwhite_share:incomeShare_difference                        0.864    0.387
## PoliticalOrientation:nonwhite_share:incomeShare_difference  -0.945    0.345
## 
## Correlation of Fixed Effects:
##             (Intr) PltclO nnwht_ incmS_ PltO:_ PlO:S_ nn_:S_
## PltclOrnttn -0.928                                          
## nonwhit_shr -0.903  0.844                                   
## incmShr_dff  0.050 -0.071 -0.040                            
## PltclOrnt:_  0.828 -0.900 -0.926  0.059                     
## PltclOrn:S_ -0.071  0.103  0.060 -0.928 -0.091              
## nnwht_sh:S_ -0.048  0.071  0.051 -0.923 -0.080  0.863       
## PltclO:_:S_  0.068 -0.105 -0.079  0.838  0.125 -0.911 -0.926
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
plot4_1 <- interact_plot(model = m4_1, pred = nonwhite_share, modx = incomeShare_difference, mod2 = PoliticalOrientation, x.label = "Non white Ratio", y.label = "0 = distrust , 1 = no distrust", legend.main = "Political Orientation") + ylim(c(0,1))

ggsave(plot = plot3_1, width = 10, height = 8, filename = "Pol_trust_nw.jpg")
interaction_polorientation <- ggarrange(plot1_1, plot2_1, plot3_1, plot4_1, ncol = 2, nrow = 2, common.legend = T)

ggsave(plot = interaction_polorientation, width = 12, height = 8, filename = "polorientation.jpg")
knitr::include_graphics("polorientation.jpg")

interaction_polorientation <- ggarrange(plot1_2, plot2_2, plot3_2, plot4_2, ncol = 2, nrow = 2, common.legend = T)

ggsave(plot = interaction_polorientation, width = 12, height = 8, filename = "polorientation_w.jpg")
knitr::include_graphics("polorientation_w.jpg")

5 Moderator Analysis: SDO

5.1 fairness

summary(m1_2 <- lme4::glmer(fairness ~ SDO *nonwhite_share*incomeShare_difference +(1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5))))
## boundary (singular) fit: see help('isSingular')
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: fairness ~ SDO * nonwhite_share * incomeShare_difference + (1 |  
##     X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    645.6    683.5   -313.8    627.6      486 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.5001 -0.7559 -0.6104  1.0671  2.6269 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0        0       
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                            Estimate Std. Error z value Pr(>|z|)
## (Intercept)                               -2.784377   1.187382  -2.345   0.0190
## SDO                                        0.442904   0.205297   2.157   0.0310
## nonwhite_share                             0.070738   0.044029   1.607   0.1081
## incomeShare_difference                     0.529894   1.032124   0.513   0.6077
## SDO:nonwhite_share                        -0.014328   0.007664  -1.870   0.0615
## SDO:incomeShare_difference                -0.147505   0.175650  -0.840   0.4010
## nonwhite_share:incomeShare_difference     -0.005186   0.034086  -0.152   0.8791
## SDO:nonwhite_share:incomeShare_difference  0.000942   0.005860   0.161   0.8723
##                                            
## (Intercept)                               *
## SDO                                       *
## nonwhite_share                             
## incomeShare_difference                     
## SDO:nonwhite_share                        .
## SDO:incomeShare_difference                 
## nonwhite_share:incomeShare_difference      
## SDO:nonwhite_share:incomeShare_difference  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) SDO    nnwht_ incmS_ SDO:n_ SDO:S_ nn_:S_
## SDO         -0.982                                          
## nonwhit_shr -0.907  0.894                                   
## incmShr_dff -0.056  0.063  0.070                            
## SDO:nnwht_s  0.887 -0.906 -0.981 -0.073                     
## SDO:ncmShr_  0.063 -0.069 -0.072 -0.983  0.074              
## nnwht_sh:S_  0.057 -0.061 -0.053 -0.932  0.052  0.919       
## SDO:nnw_:S_ -0.060  0.062  0.051  0.908 -0.048 -0.928 -0.982
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
plot1_2 <- interact_plot(model = m1_2, pred = nonwhite_share, modx = incomeShare_difference, mod2 = SDO, x.label = "Non white Ratio", y.label = "0 = fair, 1 = unfair", legend.main = "SDO") + ylim(c(0,1))

ggsave(plot = plot1_2, width = 10, height = 8, filename = "SDO_Fairness_nw.jpg")

5.2 want to work in team

summary(m2_2 <- lme4::glmer(work_in_team ~ SDO*nonwhite_share*incomeShare_difference +(1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5))))
## boundary (singular) fit: see help('isSingular')
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: work_in_team ~ SDO * nonwhite_share * incomeShare_difference +  
##     (1 | X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    669.8    707.7   -325.9    651.8      486 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.3521 -0.8730 -0.6299  0.9622  2.6346 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0        0       
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                            Estimate Std. Error z value Pr(>|z|)
## (Intercept)                               -2.193336   1.155238  -1.899   0.0576
## SDO                                        0.344407   0.199757   1.724   0.0847
## nonwhite_share                             0.087012   0.043076   2.020   0.0434
## incomeShare_difference                    -1.141173   1.014819  -1.125   0.2608
## SDO:nonwhite_share                        -0.015276   0.007491  -2.039   0.0414
## SDO:incomeShare_difference                 0.139742   0.172333   0.811   0.4174
## nonwhite_share:incomeShare_difference      0.040094   0.033702   1.190   0.2342
## SDO:nonwhite_share:incomeShare_difference -0.006982   0.005785  -1.207   0.2274
##                                            
## (Intercept)                               .
## SDO                                       .
## nonwhite_share                            *
## incomeShare_difference                     
## SDO:nonwhite_share                        *
## SDO:incomeShare_difference                 
## nonwhite_share:incomeShare_difference      
## SDO:nonwhite_share:incomeShare_difference  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) SDO    nnwht_ incmS_ SDO:n_ SDO:S_ nn_:S_
## SDO         -0.982                                          
## nonwhit_shr -0.908  0.894                                   
## incmShr_dff  0.016 -0.004  0.018                            
## SDO:nnwht_s  0.888 -0.907 -0.981 -0.025                     
## SDO:ncmShr_ -0.005 -0.008 -0.024 -0.983  0.032              
## nnwht_sh:S_  0.000 -0.009 -0.018 -0.933  0.021  0.920       
## SDO:nnw_:S_ -0.008  0.016  0.020  0.909 -0.022 -0.929 -0.982
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
plot2_2 <- interact_plot(model = m2_2, pred = nonwhite_share, modx = incomeShare_difference, mod2 = SDO, x.label = "Non white Ratio", y.label = "0 = want to work in team, 1 = do not want to work in team", legend.main = "SDO") + ylim(c(0,1))

ggsave(plot = plot2_2, width = 10, height = 8, filename = "SDO_Work_in_team_nw.jpg")

5.3 team work

summary(m3_2 <- lme4::glmer(team_work ~ SDO*nonwhite_share*incomeShare_difference +(1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5))))
## boundary (singular) fit: see help('isSingular')
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: team_work ~ SDO * nonwhite_share * incomeShare_difference + (1 |  
##     X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    523.5    561.4   -252.8    505.5      486 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.1820 -0.5473 -0.4745 -0.2420  7.0232 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0        0       
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                            Estimate Std. Error z value Pr(>|z|)
## (Intercept)                               -1.937992   1.346605  -1.439  0.15010
## SDO                                        0.091008   0.234954   0.387  0.69850
## nonwhite_share                             0.076392   0.049594   1.540  0.12347
## incomeShare_difference                    -2.229316   1.159528  -1.923  0.05453
## SDO:nonwhite_share                        -0.012556   0.008802  -1.427  0.15372
## SDO:incomeShare_difference                 0.383459   0.198544   1.931  0.05344
## nonwhite_share:incomeShare_difference      0.101918   0.038511   2.646  0.00813
## SDO:nonwhite_share:incomeShare_difference -0.019488   0.006706  -2.906  0.00366
##                                             
## (Intercept)                                 
## SDO                                         
## nonwhite_share                              
## incomeShare_difference                    . 
## SDO:nonwhite_share                          
## SDO:incomeShare_difference                . 
## nonwhite_share:incomeShare_difference     **
## SDO:nonwhite_share:incomeShare_difference **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) SDO    nnwht_ incmS_ SDO:n_ SDO:S_ nn_:S_
## SDO         -0.980                                          
## nonwhit_shr -0.911  0.899                                   
## incmShr_dff  0.109 -0.091 -0.063                            
## SDO:nnwht_s  0.882 -0.907 -0.979  0.053                     
## SDO:ncmShr_ -0.093  0.077  0.057 -0.982 -0.050              
## nnwht_sh:S_ -0.090  0.081  0.076 -0.933 -0.079  0.920       
## SDO:nnw_:S_  0.081 -0.076 -0.082  0.903  0.092 -0.926 -0.980
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
plot3_2 <- interact_plot(model = m3_2, pred = nonwhite_share, modx = incomeShare_difference, mod2 = SDO, x.label = "Non white Ratio", y.label = "0 = team work well, 1 = team work not well", legend.main = "SDO") + ylim(c(0,1))

ggsave(plot = plot3_2, width = 10, height = 8, filename = "SDO_Team_work_nw.jpg")

5.4 trust in leadership

summary(m4_2 <- lme4::glmer(distrust ~ SDO*nonwhite_share*incomeShare_difference +(1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5))))
## boundary (singular) fit: see help('isSingular')
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: distrust ~ SDO * nonwhite_share * incomeShare_difference + (1 |  
##     X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    640.7    678.6   -311.4    622.7      486 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.4067 -0.7712 -0.5864  1.0606  3.3852 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0        0       
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                            Estimate Std. Error z value Pr(>|z|)
## (Intercept)                               -2.850199   1.227719  -2.322   0.0203
## SDO                                        0.428279   0.210818   2.032   0.0422
## nonwhite_share                             0.074767   0.045220   1.653   0.0983
## incomeShare_difference                    -1.397601   1.072537  -1.303   0.1925
## SDO:nonwhite_share                        -0.014001   0.007849  -1.784   0.0745
## SDO:incomeShare_difference                 0.181591   0.181310   1.002   0.3166
## nonwhite_share:incomeShare_difference      0.066822   0.035448   1.885   0.0594
## SDO:nonwhite_share:incomeShare_difference -0.011611   0.006080  -1.910   0.0562
##                                            
## (Intercept)                               *
## SDO                                       *
## nonwhite_share                            .
## incomeShare_difference                     
## SDO:nonwhite_share                        .
## SDO:incomeShare_difference                 
## nonwhite_share:incomeShare_difference     .
## SDO:nonwhite_share:incomeShare_difference .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) SDO    nnwht_ incmS_ SDO:n_ SDO:S_ nn_:S_
## SDO         -0.983                                          
## nonwhit_shr -0.910  0.898                                   
## incmShr_dff  0.071 -0.056 -0.025                            
## SDO:nnwht_s  0.888 -0.908 -0.982  0.016                     
## SDO:ncmShr_ -0.058  0.044  0.018 -0.984 -0.010              
## nnwht_sh:S_ -0.048  0.038  0.021 -0.934 -0.018  0.923       
## SDO:nnw_:S_  0.038 -0.030 -0.019  0.909  0.019 -0.929 -0.982
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
plot4_2 <- interact_plot(model = m4_2, pred = nonwhite_share, modx = incomeShare_difference, mod2 = SDO, x.label = "Non white Ratio", y.label = "0 = Trust , 1 = distrust", legend.main = "SDO") + ylim(c(0,1))

ggsave(plot = plot4_2, width = 10, height = 8, filename = "SDO_Trust_nw.jpg")
interaction_SDO <- ggarrange(plot1_2, plot2_2, plot3_2, plot4_2, ncol = 2, nrow = 2, common.legend = T)

ggsave(plot = interaction_SDO, width = 12, height = 8, filename = "SDO.jpg")
knitr::include_graphics("SDO.jpg")

interaction_SDO <- ggarrange(plot1_22, plot2_22, plot3_22, plot4_22, ncol = 2, nrow = 2, common.legend = T)

ggsave(plot = interaction_SDO, width = 12, height = 8, filename = "SDO_w.jpg")
knitr::include_graphics("SDO_w.jpg")
## Table nw
M1_2 = Fairness nw (DV), M2_2 = Want to work in team nw(DV), M3_2 = Team work nw (DV), M4_2 = Distrust nw (DV)
  Model 1 Model 2 Model 3 Model 4
(Intercept) -2.784* -2.193 -1.938 -2.850*
  (1.187) (1.155) (1.347) (1.228)
SDO .443* .344 .091 .428*
  (.205) (.200) (.235) (.211)
nonwhite_share .071 .087* .076 .075
  (.044) (.043) (.050) (.045)
incomeShare_difference .530 -1.141 -2.229 -1.398
  (1.032) (1.015) (1.160) (1.073)
SDO:nonwhite_share -.014 -.015* -.013 -.014
  (.008) (.007) (.009) (.008)
SDO:incomeShare_difference -.148 .140 .383 .182
  (.176) (.172) (.199) (.181)
nonwhite_share:incomeShare_difference -.005 .040 .102** .067
  (.034) (.034) (.039) (.035)
SDO:nonwhite_share:incomeShare_difference .001 -.007 -.019** -.012
  (.006) (.006) (.007) (.006)
AIC 645.641 669.815 523.525 640.723
BIC 683.482 707.656 561.366 678.564
Log Likelihood -313.820 -325.908 -252.763 -311.361
Num. obs. 495 495 495 495
Num. groups: X 495 495 495 495
Var: X (Intercept) .000 .000 .000 .000
***p < 0.001; **p < 0.01; *p < 0.05

6 Moderator Analysis: Race

6.1 fairness

summary(m1_44 <- lme4::glmer(fairness ~ ethnic *nonwhite_share*incomeShare_difference +(1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5))))
## boundary (singular) fit: see help('isSingular')
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: fairness ~ ethnic * nonwhite_share * incomeShare_difference +  
##     (1 | X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    649.0    686.8   -315.5    631.0      486 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.2076 -0.7471 -0.6211  1.0582  2.0223 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0        0       
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                                Estimate Std. Error z value
## (Intercept)                                   -0.149467   0.262075  -0.570
## ethnic1                                       -0.535749   0.491110  -1.091
## nonwhite_share                                -0.010842   0.009987  -1.086
## incomeShare_difference                        -0.399857   0.216778  -1.845
## ethnic1:nonwhite_share                         0.004979   0.018778   0.265
## ethnic1:incomeShare_difference                 0.407509   0.432232   0.943
## nonwhite_share:incomeShare_difference          0.002955   0.007457   0.396
## ethnic1:nonwhite_share:incomeShare_difference -0.010477   0.014787  -0.709
##                                               Pr(>|z|)  
## (Intercept)                                     0.5685  
## ethnic1                                         0.2753  
## nonwhite_share                                  0.2777  
## incomeShare_difference                          0.0651 .
## ethnic1:nonwhite_share                          0.7909  
## ethnic1:incomeShare_difference                  0.3458  
## nonwhite_share:incomeShare_difference           0.6919  
## ethnic1:nonwhite_share:incomeShare_difference   0.4786  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) ethnc1 nnwht_ incmS_ eth1:_ et1:S_ nn_:S_
## ethnic1     -0.534                                          
## nonwhit_shr -0.903  0.482                                   
## incmShr_dff  0.052 -0.028 -0.038                            
## ethnc1:nnw_  0.480 -0.902 -0.532  0.020                     
## ethnc1:ncS_ -0.026 -0.028  0.019 -0.502  0.004              
## nnwht_sh:S_ -0.045  0.024  0.044 -0.922 -0.023  0.463       
## ethnc1:_:S_  0.023  0.003 -0.022  0.465  0.035 -0.924 -0.504
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
plot1_44 <- interactions::interact_plot(m1_44, pred = incomeShare_difference, modx = ethnic, x.label = "Non white Ratio", y.label = "0 = fair, 1 = unfair", legend.main = "own ethnicity") + ylim(c(0,1), (legend = "0 = White, 1 = Non white"))

ggsave(plot = plot1_44, width = 10, height = 8, filename = "Race_fairness_nw.jpg")

6.2 want to work in team

summary(m2_4 <- lme4::glmer(work_in_team ~ ethnic*nonwhite_share*incomeShare_difference +(1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5))))
## boundary (singular) fit: see help('isSingular')
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: work_in_team ~ ethnic * nonwhite_share * incomeShare_difference +  
##     (1 | X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    676.1    713.9   -329.1    658.1      486 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.3215 -0.9049 -0.6685  0.9845  1.7455 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0        0       
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                                 Estimate Std. Error z value
## (Intercept)                                   -0.2023802  0.2586555  -0.782
## ethnic1                                       -0.1498902  0.4736075  -0.316
## nonwhite_share                                 0.0003096  0.0097882   0.032
## incomeShare_difference                        -0.3246762  0.2133826  -1.522
## ethnic1:nonwhite_share                         0.0024577  0.0179001   0.137
## ethnic1:incomeShare_difference                -0.0348817  0.4217330  -0.083
## nonwhite_share:incomeShare_difference          0.0006419  0.0073063   0.088
## ethnic1:nonwhite_share:incomeShare_difference -0.0003778  0.0143409  -0.026
##                                               Pr(>|z|)
## (Intercept)                                      0.434
## ethnic1                                          0.752
## nonwhite_share                                   0.975
## incomeShare_difference                           0.128
## ethnic1:nonwhite_share                           0.891
## ethnic1:incomeShare_difference                   0.934
## nonwhite_share:incomeShare_difference            0.930
## ethnic1:nonwhite_share:incomeShare_difference    0.979
## 
## Correlation of Fixed Effects:
##             (Intr) ethnc1 nnwht_ incmS_ eth1:_ et1:S_ nn_:S_
## ethnic1     -0.546                                          
## nonwhit_shr -0.904  0.494                                   
## incmShr_dff  0.023 -0.013 -0.007                            
## ethnc1:nnw_  0.494 -0.904 -0.547  0.004                     
## ethnc1:ncS_ -0.012 -0.026  0.004 -0.506  0.016              
## nnwht_sh:S_ -0.012  0.006 -0.002 -0.923  0.001  0.467       
## ethnc1:_:S_  0.006  0.017  0.001  0.470 -0.002 -0.926 -0.509
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
plot2_4 <- interactions::interact_plot(m2_4, pred = incomeShare_difference, modx = ethnic, x.label = "Non white Ratio", y.label = "0 = want to work in team, 1 = do not want to work in team", legend.main = "ethnic") + ylim(c(0,1),(legend = "0 = White, 1 = Non white"))

6.3 team work

summary(m3_4 <- lme4::glmer(team_work ~ ethnic*nonwhite_share*incomeShare_difference +(1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5))))
## boundary (singular) fit: see help('isSingular')
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: team_work ~ ethnic * nonwhite_share * incomeShare_difference +  
##     (1 | X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    540.5    578.3   -261.2    522.5      486 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -0.8975 -0.5690 -0.4967 -0.3897  2.7327 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0        0       
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                                Estimate Std. Error z value
## (Intercept)                                   -1.500647   0.317318  -4.729
## ethnic1                                        0.026260   0.564096   0.047
## nonwhite_share                                 0.009679   0.011805   0.820
## incomeShare_difference                        -0.136890   0.258194  -0.530
## ethnic1:nonwhite_share                         0.003419   0.020758   0.165
## ethnic1:incomeShare_difference                 0.135096   0.492268   0.274
## nonwhite_share:incomeShare_difference         -0.005549   0.008744  -0.635
## ethnic1:nonwhite_share:incomeShare_difference  0.002329   0.016367   0.142
##                                               Pr(>|z|)    
## (Intercept)                                   2.25e-06 ***
## ethnic1                                          0.963    
## nonwhite_share                                   0.412    
## incomeShare_difference                           0.596    
## ethnic1:nonwhite_share                           0.869    
## ethnic1:incomeShare_difference                   0.784    
## nonwhite_share:incomeShare_difference            0.526    
## ethnic1:nonwhite_share:incomeShare_difference    0.887    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) ethnc1 nnwht_ incmS_ eth1:_ et1:S_ nn_:S_
## ethnic1     -0.563                                          
## nonwhit_shr -0.908  0.510                                   
## incmShr_dff  0.147 -0.082 -0.127                            
## ethnc1:nnw_  0.516 -0.910 -0.569  0.072                     
## ethnc1:ncS_ -0.077 -0.006  0.067 -0.524 -0.010              
## nnwht_sh:S_ -0.143  0.081  0.157 -0.927 -0.089  0.486       
## ethnc1:_:S_  0.077 -0.012 -0.084  0.495  0.043 -0.931 -0.534
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
plot3_4 <- interactions::interact_plot(m3_4, pred = incomeShare_difference, modx = ethnic, x.label = "Non white Ratio", y.label = "0 = team work well, 1 = team work not well", legend.main = "ethnic") + ylim(c(0,1), (legend = "0 = White, 1 = Non white"))

6.4 distrust

summary(m4_4 <- lme4::glmer(distrust ~ ethnic*nonwhite_share*incomeShare_difference +(1 | X), cd, family = binomial(link = "logit"),control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5))))
## boundary (singular) fit: see help('isSingular')
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: distrust ~ ethnic * nonwhite_share * incomeShare_difference +  
##     (1 | X)
##    Data: cd
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    647.3    685.1   -314.6    629.3      486 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.2281 -0.7377 -0.5948  1.0908  2.1482 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  X      (Intercept) 0        0       
## Number of obs: 495, groups:  X, 495
## 
## Fixed effects:
##                                                Estimate Std. Error z value
## (Intercept)                                   -0.371885   0.268342  -1.386
## ethnic1                                       -0.306616   0.486601  -0.630
## nonwhite_share                                -0.004681   0.010208  -0.459
## incomeShare_difference                        -0.472117   0.223627  -2.111
## ethnic1:nonwhite_share                         0.006489   0.018327   0.354
## ethnic1:incomeShare_difference                 0.515371   0.427842   1.205
## nonwhite_share:incomeShare_difference          0.002102   0.007703   0.273
## ethnic1:nonwhite_share:incomeShare_difference -0.004671   0.014516  -0.322
##                                               Pr(>|z|)  
## (Intercept)                                     0.1658  
## ethnic1                                         0.5286  
## nonwhite_share                                  0.6465  
## incomeShare_difference                          0.0348 *
## ethnic1:nonwhite_share                          0.7233  
## ethnic1:incomeShare_difference                  0.2284  
## nonwhite_share:incomeShare_difference           0.7850  
## ethnic1:nonwhite_share:incomeShare_difference   0.7476  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) ethnc1 nnwht_ incmS_ eth1:_ et1:S_ nn_:S_
## ethnic1     -0.551                                          
## nonwhit_shr -0.903  0.498                                   
## incmShr_dff  0.097 -0.054 -0.076                            
## ethnc1:nnw_  0.503 -0.905 -0.557  0.042                     
## ethnc1:ncS_ -0.051 -0.046  0.040 -0.523  0.028              
## nnwht_sh:S_ -0.088  0.048  0.086 -0.922 -0.048  0.482       
## ethnc1:_:S_  0.047  0.031 -0.046  0.489 -0.009 -0.926 -0.531
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
plot4_4 <- interactions::interact_plot(m4_4, pred = incomeShare_difference, modx = ethnic, x.label = "Non white Ratio", y.label = "0 = distrust , 1 = no distrust", legend.main = "ethnic") + ylim(c(0,1), (legend = "0 = White, 1 = Non white"))
interaction_ethnic <- ggarrange(plot1_44
                                , plot2_4, plot3_4, plot4_4, ncol = 2, nrow = 2, common.legend = T)

ggsave(plot = interaction_ethnic, width = 10, height = 8, filename = "ethnic.jpg")
knitr::include_graphics("ethnic.jpg")